package com.DB;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;



public class DBSelectHelper {
	/**
	 * 从表eva_items中得到所有的关于question的信息
	 * @return
	 */
	public static List<String> getAllProblemAnswer(String question)
	{
		
		List<String> engCap=new ArrayList<String>();
		String sql="select answer from eva_items where question=?";
		Connection conn;
	    try {
			conn=jdbcUtil.getConnection();
			PreparedStatement pstmst=conn.prepareStatement(sql);
			pstmst.setString(1, question);
			ResultSet rs=pstmst.executeQuery();
			while(rs.next())
			{
				engCap.add(rs.getString(1));
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    
		return engCap;
	}
	public static List<String>getAllQuestionFromEva_item()
	{
		List<String> questionList=new ArrayList<>();
		String sql="select distinct(question) from eva_items";
		Connection conn;
	    try {
			conn=jdbcUtil.getConnection();
			PreparedStatement pstmst=conn.prepareStatement(sql);
			ResultSet rs=pstmst.executeQuery();
			while(rs.next())
			{
				questionList.add(rs.getString(1));
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    return questionList;
		
	}
	public static void main(String []args)
	{
		String question="1、与提名职业相关的澳大利亚境外工作经历";
		List<String> list=getAllProblemAnswer(question);
		for(int i=0;i<list.size();i++)
		{
			System.out.println(list.get(i));
		}
	}

}
